#ifndef TOKENIZER_H_
#define TOKENIZER_H_

#include <string>
#include <stack>

namespace oputils {

typedef std::stack<std::string> strstack;
typedef std::stack<long int> listack;

typedef struct OperatorData_s
{
	std::string plus;
	std::string minus;
	std::string multiply;
	std::string lparanthesis;
	std::string rparanthesis;
} OperatorData;

class Tokenizer {
public:
	Tokenizer();
	virtual ~Tokenizer();

	//transforms expression from infix form to prefix and calculates the result
	long int calculateExpression(const std::string& input) const ;

private:
	long int doPrefixOperation(strstack& operatorStack, listack& operandStack) const;
	long int doOperation(const std::string& operation, const long int& operand1, const long int& operand2) const;

	int getOpHierarchy(const std::string& op) const;
	long int getNumberFromString(const std::string& str) const;
	bool isValidDigit(char c) const;

	OperatorData m_opData;
};

} /* namespace oputils */
#endif /* TOKENIZER_H_ */
